﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using CI;
using CI.Interfaces;
using System.IO;

namespace Globals.SystemTests
{
    [TestFixture]
    public class RoboticsConfig
    {
        /// <summary>
        /// Test to check that scenario files are deleted
        /// </summary>
        [Test]
        public void DeleteScenarioFilesTrue()
        {
            // copy the scenario file
            CI.Utils.RoboticsConfig.CopyScenarioFiles();

            Assert.IsTrue(File.Exists(Path.Combine(CI.Utils.ResourceFolders.UsersResourceFolder(), CI.Utils.RoboticsConfig.ScenarioFiles[0])), "scenario file not created");

            // run method
            CI.Utils.RoboticsConfig.DeleteScenarioFiles();

            // make sure file is not their now
            Assert.IsFalse(File.Exists(Path.Combine(CI.Utils.ResourceFolders.UsersResourceFolder(), CI.Utils.RoboticsConfig.ScenarioFiles[0])), "scenario file not deleted");
            
        }

        /// <summary>
        /// Test to check that scenario files are copied
        /// </summary>
        [Test]
        public void CopyScenarioFilesTrue()
        {
            // delete any existing files
            CI.Utils.RoboticsConfig.DeleteScenarioFiles();

            // make sure file is not their now
            Assert.IsFalse(File.Exists(Path.Combine(CI.Utils.ResourceFolders.UsersResourceFolder(), CI.Utils.RoboticsConfig.ScenarioFiles[0])), "scenario file not deleted");

            // copy the scenario file
            CI.Utils.RoboticsConfig.CopyScenarioFiles();

            Assert.IsTrue(File.Exists(Path.Combine(CI.Utils.ResourceFolders.UsersResourceFolder(), CI.Utils.RoboticsConfig.ScenarioFiles[0])), "scenario file not created");
        }

        /// <summary>
        /// Find the robotics folder using the files system
        /// </summary>
        [Test]
        public void FindRoboticsFoldersExistsTrue()
        {
            Assert.IsTrue(Directory.Exists(CI.Utils.RoboticsConfig.FindRoboticsFolders()), "Robotics folder not found");
        }

        /// <summary>
        /// search the registry for the robotics folder
        /// </summary>
        [Test]
        public void SearchRegistryRoboticsFolderExistsTrue()
        {
            Assert.IsTrue(Directory.Exists(CI.Utils.RoboticsConfig.SearchRegistryRoboticsFolder()), "Robotics folder not found");
        }


        /// <summary>
        /// Check that the robotics folder found in search and registry is the same
        /// </summary>
        [Test]
        public void FindRoboticsFoldersEqualsSearchRegistryRoboticsFolder()
        {
            Assert.AreEqual(CI.Utils.RoboticsConfig.FindRoboticsFolders().ToLower(), CI.Utils.RoboticsConfig.SearchRegistryRoboticsFolder().ToLower(), "Robotics folder found by folders and reg search not equal");
        }


    }
}
